package azheng.apps.starclouddemo.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

/**
 * @author azheng
 * @date 2018/8/16.
 * GitHub：https://github.com/RookieExaminer
 * Email：wei.azheng@foxmail.com
 * Description：
 */
public class XingView extends View {

    List<Integer> mListView;

    // 设置画笔变量
    Paint mPaint;

    public XingView(Context context) {
        super(context);
        init();
    }

    public XingView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    // 画笔初始化
    private void init() {
        mListView = new ArrayList<>();
        mListView.add(1);
        mListView.add(2);
        mListView.add(3);
        mListView.add(4);
        // 创建画笔
        mPaint = new Paint ();
        // 设置画笔颜色为白色
        mPaint.setColor(Color.RED);
        // 设置画笔宽度为10px
        mPaint.setStrokeWidth(1f);
        //设置画笔模式为填充
        mPaint.setStyle(Paint.Style.FILL);

    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);

    }

    // 复写onDraw()进行绘制
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        // 获取控件的高度和宽度
        int width = 200;
        int height = 200;

        // 设置圆的半径 = 宽,高最小值的2分之1
        int r = Math.min(width, height)/2;

        Paint mPaint1= new Paint ();
        // 创建画笔

        // 设置画笔颜色为白色
        // 消除锯齿
        mPaint1.setAntiAlias(true);
        mPaint1.setColor(Color.RED);
        // 设置画笔宽度为10px
        mPaint1.setStrokeWidth(1f);
        //设置画笔模式为填充
        mPaint1.setStyle(Paint.Style.STROKE);
        //  设置笔触为圆形
        mPaint1.setStrokeCap(Paint.Cap.ROUND);

        // 圆心 = 控件的中央,半径 = 宽,高最小值的2分之1
        canvas.drawCircle(width/2,height/2,r,mPaint);


        canvas.drawCircle(width/2,height/2,r,mPaint1);



//            canvas.drawLine(10, 10, 10, 10, mPaint);




    }

}
